#include "stdafx.h"
#include "ImageMenuItem.h"

CImageMenuItem::CImageMenuItem(int menuID, hgeSprite* sprite, hgeSprite* focusSprite, float x, float y)
    : m_x(x)
    , m_y(y)
    , m_sprite(sprite)
    , m_focusSprite(focusSprite)
    , m_focus(false)
{
    this->id = menuID;
    this->bVisible = true;
    this->bEnabled = true;
    this->bStatic = false;

    m_sprite->SetHotSpot(m_sprite->GetWidth()/2, m_sprite->GetHeight()/2);
    m_focusSprite->SetHotSpot(m_focusSprite->GetWidth()/2, m_focusSprite->GetHeight()/2);
}

CImageMenuItem::~CImageMenuItem()
{
    if (m_focusSprite != NULL)
    {
        delete m_focusSprite;
    }
    if (m_sprite != NULL)
    {
        delete m_sprite;
    }
}

void CImageMenuItem::Render()
{
    if (m_focus)
    {
        if (m_focusSprite != NULL)
        {
            m_focusSprite->Render(m_x, m_y);
        }         
    }
    else
    {
        if (m_sprite != NULL)
        {
            m_sprite->Render(m_x, m_y);
        }        
    }
}

void CImageMenuItem::Focus(bool bFocused)
{
    m_focus = bFocused;
}

bool CImageMenuItem::KeyClick(int key, int chr)
{
    if (key == HGEK_ENTER)
    {
        return true;
    }
    else
    {
        return false;
    }
}